$(function () {
    if(subjectIds==''){
        //初始化专业搜索条件
        $.initSubject({
            element:'subject-box',
            confirmBtn:false,
            removeBtn: false,
            style:false,
            notMultiple:true,
            classText:'form-control mb10',
            width:100,
            selectCallback:function(subjectIds){
                $("#subjectIds").val(subjectIds);
            }
        });
    }

    $("body").on('click', '#btn1,#btn2', function () { //搜索课程
        getCourseOpenData(1);
    });
    getCourseOpenData(1);

    function getCourseOpenData(pageNo) {
        var params = $("#search-form").serializeJSON();
        params = JSON.stringify(params);
        var obj = {
            url: baseloaction + '/admin/course/open/selectAjaxCourseOpenList',//请求URL
            contextId: 'courseOpen-list-context',//响应内容页面设置内容ID
            params: params,//请求参数
            pageNo: pageNo,//页码
            pageCall: getCourseOpenData, //分页回调加载数据(点击上下页时调用,该方法也在加载页面完成时调用)
            selectAllId: 'select-all-courseOpen', //全选框ID
            callback: function () {//数据加载完成回调
                //$("#count").html('(共'+total+'个模块)');
            }
        };
        ajaxGetListData(obj);
    }
});

function getSelectOpenCourse() {
    var input = $('#courseOpen-list-context input.i-checks:checked');
    if(input.length==0){
        icModale(0,"请选择免费直播课程数据");
        return null;
    }
    var result = null;
    if(selectType==null || $.trim(selectType)=='' || typeof  selectType =='undefined' || selectType=='radio'){
        var _m = $(input[0]);
        var id = _m.val();
        var courseName = $.trim($("#courseOpen-name-"+id).text());
        var subjectName = $.trim($("#courseOpen-subject-"+id).text());
        var time = $.trim($("#courseOpen-time-"+id).text());

        result = {
            'id':id,
            'courseName':courseName,
            'subjectName':subjectName,
            'time':time
        };
    }else{
        result = new Array();
        $.each(input,function (index,_m) {
            _m = $(_m);
            var id = _m.val();
            var courseName = $.trim($("#courseOpen-name-"+id).text());
            var subjectName = $.trim($("#courseOpen-subject-"+id).text());
            var time = $.trim($("#courseOpen-time-"+id).text());
            var openCourse = {
                'id':id,
                'courseName':courseName,
                'subjectName':subjectName,
                'time':time
            };
            result.push(openCourse);
        });
    }
    return result;
}